home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / jazlib.arc / JZPSHDIR.C < prev    next >
Text File  |  1988-12-18  |  2KB  |  51 lines

  1. #include <jaz.h>
  2.  
  3. /*
  4. ┌────────────────────────────────────────────────────────────────────────────┐
  5. │jzpshdir.c                                     │
  6. │Push the current subdirectory and drive.                     │
  7. │Synopsis                                     │
  8. │  TSTKHEAD whead;                                 │
  9. │                                         │
  10. │  jzpshdir(&whead);     ( current sub directory and drive saved now )         │
  11. │  chdir("\\test");                                                          │
  12. │                                         │
  13. └────────────────────────────────────────────────────────────────────────────┘
  14. */
  15.  
  16. jzpshdir(fhead)
  17. TSTKHEAD *fhead;        /* head of stack structure */
  18. {
  19.   TSTACK *wtemp;
  20.   char wpath[65];
  21.   int wdrive;
  22.  
  23.   jzgetdr(wpath);        /* return path string */
  24.  
  25.   /**
  26.    ** We will save the drive in the first
  27.    ** byte of the buffer, and the path
  28.    ** in the remaining bytes!
  29.    **/
  30.  
  31.   wtemp = (TSTACK *)  malloc(sizeof(TSTACK));        /* get pointer to struct */
  32.   wtemp->pointer = (char *) malloc(strlen(wpath)+1);   /* space for path */
  33.  
  34.   strcpy(wtemp->pointer,wpath);     /* copy the path */
  35.   wtemp->wint = jzgetdrv();        /* get default drive in size variable */
  36.  
  37.   if (fhead->last == 0) {     /* empty stack */
  38.     wtemp->prev  = 0;
  39.     fhead->last  =  wtemp;    /* set last item (top of stack) */
  40.     fhead->first =  wtemp;    /* set first item */
  41.     fhead->numitems = 1;    /* set number of items */
  42.   }
  43.   else {
  44.     wtemp->prev = fhead->last;    /* set link to stack top */
  45.     fhead->last = wtemp;    /* set new top of stack */
  46.     fhead->numitems++;        /* increment stack pointer */
  47.   }
  48. }
  49.  
  50.  
  51.